package com.cuiyun97.controller.admin;

import com.cuiyun97.domain.po.SetJwt;
import com.cuiyun97.domain.po.SetOss;
import com.cuiyun97.domain.po.SetSms;
import com.cuiyun97.result.Result;
import com.cuiyun97.service.SettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@Api(tags = "参数设置")
@RequestMapping("/admin/settings")
public class SettingController {

    @Resource
    private SettingService settingService;

    @GetMapping("/jwt")
    @ApiOperation("查询jwt配置")
    public Result queryJwt() {
        SetJwt setJwt = settingService.queryJwt();
        return Result.success(setJwt);
    }

    @PutMapping("/jwt")
    @ApiOperation("修改jwt配置")
    public Result updateJwt(@RequestBody SetJwt lastOne) {
        settingService.updateJwt(lastOne);
        return Result.success();
    }

    @GetMapping("/sms")
    @ApiOperation("查询sms配置")
    public Result querySms() {
        SetSms setSms = settingService.querySms();
        return Result.success(setSms);
    }

    @PutMapping("/sms")
    @ApiOperation("修改sms配置")
    public Result updateSms(@RequestBody SetSms lastOne) {
        settingService.updateSms(lastOne);
        return Result.success();
    }

    @GetMapping("/oss")
    @ApiOperation("查询oss配置")
    public Result queryOss() {
        SetOss setOss = settingService.queryOss();
        return Result.success(setOss);
    }

    @PutMapping("/oss")
    @ApiOperation("修改oss配置")
    public Result updateOss(@RequestBody SetOss lastOne) {
        settingService.updateOss(lastOne);
        return Result.success();
    }

}
